<template>
  <div class="box">
    <van-nav-bar
      title="京东注册"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="input" style="padding: 50px 0px">
      <van-form @submit="onSubmit">
        <!-- 可以使用 CellGroup 作为容器 -->
        <van-cell-group inset>
          <van-field
            v-model="value"
            label="密码"
            placeholder="至少6位,包含数字,大小写字母"
          />
        </van-cell-group>
        <div style="margin: 80px 10px">
          <van-button round block type="primary" native-type="submit">
            完成
          </van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { showDialog } from "vant";
import { reigstok } from "../../service/regist";
import { ref } from "vue";
import { useRouter } from "vue-router";
import { useCounterStore } from "@/stores/counter";
// import { useStore } from "vuex";
let router = useRouter();
// let store = useStore();
let store =useCounterStore();
let value = ref("");
function onClickLeft() {
  history.back();
}
function onSubmit() {
  reigstok({ tel:store.tel, password: value.value }).then((res) => {
    console.log(res);
    if (res.data.code === "200") {
      showDialog({
        title: "注册完成",
        message: "恭喜注册完成",
      }).then(() => {
        router.push("/login");
      });
    }
  });
}
</script>

<style lang="scss" scoped>
.box {
  background-color: #f5f5f5;
  height: 100vh;
}
.input {
  margin: 10px;
}
</style>
